package com.bocaizp.operation.controller.admin;

import com.bocaizp.common.result.Result;
import com.bocaizp.operation.service.UserInfoService;
import com.bocaizp.pojo.VO.EmployeeVO;
import com.bocaizp.pojo.entity.Employee;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Author : huang jie
 * Date : 2024/5/13 17:32
 **/
@RestController
@RequestMapping("/admin/employee")
@Slf4j
@CrossOrigin
public class EmployeeController{

	@Autowired
	private UserInfoService userInfoService;

	/**
	 * 员工信息
	 * @return
	 */
	@PostMapping("/info")
	public Result<List<EmployeeVO>> employeeInfo(){
		log.info("员工信息请求...");
		List<EmployeeVO> employeeVOS = userInfoService.getEmployeeInfo();
		return Result.success(employeeVOS);
	}

	@PostMapping("/add")
	public Result<Integer> addEmployee(@RequestBody Employee employee){
		log.info("新增员工请求...");
		int empId = userInfoService.addEmloyee(employee);

		return Result.success(empId);
	}

}
